import { observable, action } from 'mobx'
import * as api from 'lib/constants/api'
import { post } from 'lib/net'
import Toast from 'components/toast'
import Load from 'components/load'

// class AddressModel {
//   constructor (data) {
//     if (data) {
//     }
//   }
// }

export default class UserCenterVM {
  constructor (props) {
    this.props = props
    this.PageInitialization()
  }
  @action componentDidMount = () => {
  }
  // 个人中心用户信息
  @observable userValue = {}

  // 跳转到修改手机号密码页面
  @action handerToChange = (number) => {
    this.props.history.push(`/setUp?${number}`)
  }

  // 跳转到提现页面
  @action handerToWithdraw = () => {
    this.props.history.push('/withdraw')
  }

  // 跳转到提现页面
  @action handerToCommission = () => {
    this.props.history.push('/checkCommission')
  }

  // 跳转到客户投诉记录
  @action handleToAccuseRecord = () => {
    this.props.history.push('/accuseRecord')
  }

  // 跳转到销售必备
  @action handleToSaleNecessary = () => {
    this.props.history.push('/saleNecessary')
  }

  // 跳转到意见反馈
  @action handleToAdvise = () => {
    this.props.history.push('/advise')
  }

  // 跳转到营销攻略
  @action handleMarketingStrategy = () => {
    this.props.history.push('/marketingStrategy')
  }

  @action PageInitialization = async () => {
    Load.loading(1, '加载中')
    const UserId = window.localStorage.getItem('UserId')
    let response = await post(api.WZUSERBANLANCE, { WZId: UserId })
    if (response.Success) {
      Load.loading(2, '加载完成')
      this.userValue = response.Value
    } else {
      Toast.fail(response.Message)
    }
  }
}
